import request from '@/utils/request'

// 查询客户列表
export function listInfo(query) {
  return request({
    url: '/crmcustomer/info/list',
    method: 'POST',
    data: query
  })
}

// 查询客户详细
export function getInfo(
  customerId) {
  return request({
    url: '/crmcustomer/info/' +
      customerId,
    method: 'get'
  })
}

// 新增客户
export function addInfo(data) {
  return request({
    url: '/crmcustomer/info',
    method: 'post',
    data: data
  })
}

// 修改客户
export function updateInfo(data) {
  return request({
    url: '/crmcustomer/info',
    method: 'put',
    data: data
  })
}

// 删除客户
export function delInfo(
  customerId) {
  return request({
    url: '/crmcustomer/info/' +
      customerId,
    method: 'delete'
  })
}

//获取合同
export function download(
  customerId) {
  return request({
    url: '/crmcustomer/info/download/' +
      customerId,
    method: 'get',
    responseType: 'blob',
  })
}

//导出
export function downloadFile(data) {
  return request({
    url: '/crmcustomer/info/export',
    data: data,
    method: 'post',
    responseType: 'blob',
  })
}

// 转换意向客户
export function switchingIntentionClient(
  customerId) {
  return request({
    url: '/crmcustomer/info/exchange/' +
      customerId,
    method: 'get'
  })
}

//导入
export function importData(customerId, list) {
  const files = new FormData();
  list.forEach(file =>{
    console.log(file)
    files.append("files",file)
  })
    return request({
      url: `/crmcustomer/info/importData/${customerId}`,
      method: 'post',
      headers: {
        'Content-Type': 'multipart/form-data',
      },
      data: files
    });
  }

//查询客户详情明细
  export function getCustomerDetails(
    customerId,data) {
    return request({
      url: '/customerdetails/info/custom/details/' +
        customerId,
      method: 'post',
      data:data
    })
  }

//全部筛查
export function reptileAll(data) {
  return request({
    url: '/crmcustomer/info/reptileAll',
    method: 'post',
    data:data
  })
}

//拖贫校验
export function reptileUnemployment(data) {
  return request({
    url: '/crmcustomer/info/reptileUnemployment',
    method: 'post',
    data:data
  })
}

//失业筛查
export function reptileIdentity(data) {
  return request({
    url: '/crmcustomer/info/reptileIdentity',
    method: 'post',
    data:data
  })
}

//退役筛查
export function reptileRetired(data) {
  return request({
    url: '/crmcustomer/info/reptileRetired',
    method: 'post',
    data:data
  })
}

//重新计算
export function reptilallchick(data) {
  return request({
    url: '/crmcustomer/info/reptilallchick',
    method: 'post',
    data:data
  })
}

//导出
export function exportList(data) {
  return request({
    url: '/customerdetails/info/export',
    method: 'post',
    data:data,
    responseType: 'blob',
  })
}


export function deleteDetailList(id) {
  return request({
    url: '/customerdetails/info/customer/details/delete/'+id,
    method: 'delete'
  })
}


export function realTime(customerId) {
  return request({
    url: '/crmcustomer/info/realTime/'+customerId,
    method: 'get'
  })
}

